#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;

    string reverseWords(string s)
    {
        int n = 0;
        string s1 = s;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] = ' ')
            {
                reverse(s1.begin() + n, s1.begin() + i);
                n = n + i;
            }
        }
        return s1;
    }
int main()
{
    string s = { "Let's take LeetCode contest" };
    string s2 = reverseWords(s);

    return 0;
}